package com.wanxi.test;

import java.util.Scanner;

public class SumScanner {
    public static void main(String[] args) {
        //        1.创建数组
//        int[] arr={12,3,4,5,6,7};
        int[] arr = new int[5];
//        arr[0]=1;
//        arr[0]=1;
//        arr[0]=1;
//        arr[0]=1;
//        arr[0]=1;
        Scanner scanner = new Scanner(System.in);
//        ctrl+shift+up/down
        for (int i = 0; i < arr.length; i++) {
            System.out.println("请输入第 " + (i + 1) + " 个元素");
            arr[i] = scanner.nextInt();
        }

        int sum = 0;
        int max = 0;
//        int avg = 0;
//        3.遍历数组
        for (int i = 0; i < arr.length; i++) {
            max = max > arr[i] ? max : arr[i];
            sum += arr[i];

        }
        System.out.println("平均值为： " + sum / arr.length * 1.0);
        System.out.println("和为： " + sum);
        System.out.println("最大值为： " + max);
    }
}
